package com.springcloud.eshop.product.controller;

import com.springcloud.eshop.entity.ProductIntro;
import com.springcloud.eshop.product.service.ProductIntroService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * (ProductIntro)表控制层
 *
 * @author makejava
 * @since 2020-06-29 05:49:46
 */
@RestController
@RequestMapping("/productIntro")
public class ProductIntroController {
    /**
     * 服务对象
     */
    @Resource
    private ProductIntroService productIntroService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @RequestMapping("/selectOne")
    @ResponseBody
    public ProductIntro selectOne(Long id) {
        return this.productIntroService.queryById(id);
    }

    @RequestMapping("/selectOneByProductId")
    @ResponseBody
    public ProductIntro selectOneByProductId(long productId) {
        return this.productIntroService.queryByProductId(productId);
    }

    @RequestMapping("/insert")
    @ResponseBody
    public ProductIntro insert(ProductIntro product) {
        return this.productIntroService.insert(product);
    }

    @RequestMapping("/update")
    @ResponseBody
    public ProductIntro update(ProductIntro product) {
        return this.productIntroService.update(product);
    }

    @RequestMapping("/delete")
    @ResponseBody
    public boolean deleteById(Long id) {
        return this.productIntroService.deleteById(id);
    }
}